﻿using IterationLife.Datas;
using IterationLife.Domains.Sports.Models;
using IterationLife.Domains.Sports.Queries;
using IterationLife.Domains.Sports.Repositories;
using IterationLife.Football.MTSports.Contracts.Sports;
using IterationLife.Football.MTSports.Dtos.Sports;
using Util.Applications;
using Util.Datas.Queries;

namespace IterationLife.Football.MTSports.Impl.Sports
{
    /// <summary>
    /// 体育队伍服务
    /// </summary>
    public class SportTeamService : ApplicationServiceBase<SportTeam, SportTeamDto, SportTeamQuery>, ISportTeamService
    {
        /// <summary>
        /// 初始化体育队伍服务
        /// </summary>
        /// <param name="unitOfWork">工作单元</param>
        /// <param name="sportTeamRepository">体育队伍仓储</param>
        public SportTeamService(IApplicationUnitOfWork unitOfWork, ISportTeamRepository sportTeamRepository)
            : base(unitOfWork, sportTeamRepository)
        {
            SportTeamRepository = sportTeamRepository;
        }

        /// <summary>
        /// 体育队伍仓储
        /// </summary>
        protected ISportTeamRepository SportTeamRepository { get; set; }

        /// <summary>
        /// 转换为数据传输对象
        /// </summary>
        /// <param name="entity">实体</param>
        protected override SportTeamDto ToDto(SportTeam entity)
        {
            return entity.ToDto();
        }

        /// <summary>
        /// 转换为实体
        /// </summary>
        /// <param name="dto">数据传输对象</param>
        protected override SportTeam ToEntity(SportTeamDto dto)
        {
            return dto.ToEntity();
        }

        /// <summary>
        /// 创建查询对象
        /// </summary>
        /// <param name="param">体育队伍查询实体</param>
        protected override IQueryBase<SportTeam> CreateQuery(SportTeamQuery param)
        {
            return new Query<SportTeam>(param);
        }
    }
}